Allow using $TBF_READLEN to specify the size of the chunks that are read
authorElliot Lee <sopwith@src.gnome.org>
Tue, 2 Nov 1999 22:01:43 +0000 (22:01 +0000)
committerElliot Lee <sopwith@src.gnome.org>
Tue, 2 Nov 1999 22:01:43 +0000 (22:01 +0000)
* src/testpixbuf.c: Allow using $TBF_READLEN to specify the size of the chunks that are read from
the input file.

demos/testpixbuf.c
gdk-pixbuf/ChangeLog

index 7309a41a9263a6aa21325691e0aee63e236d6f60..350b4cba1eef095d3037f711c470821cb60baf99 100644 (file)
@@ -439,11 +439,13 @@ progressive_prepared_callback(GdkPixbufLoader* loader, gpointer data)
         return;
 }
 
+static int readlen = 1;
+
 int
 main (int argc, char **argv)
 {
        int i;
-       int found_valid = FALSE; 
+       int found_valid = FALSE;
 
        GdkPixbuf *pixbuf;
        GdkPixbufLoader *pixbuf_loader;
@@ -460,6 +462,11 @@ main (int argc, char **argv)
        gtk_widget_set_default_colormap (gdk_rgb_get_cmap ());
        gtk_widget_set_default_visual (gdk_rgb_get_visual ());
 
+       {
+               char *tbf_readlen = getenv("TBF_READLEN");
+               if(tbf_readlen) readlen = atoi(tbf_readlen);
+       }
+
        i = 1;
        if (argc == 1) {
                 const gchar*** xpmp;
@@ -494,6 +501,7 @@ main (int argc, char **argv)
                 {
                         GtkWidget* rgb_window = NULL;
                         guint timeout;
+                       char *buf;
 
                         pixbuf_loader = gdk_pixbuf_loader_new ();
 
@@ -506,25 +514,22 @@ main (int argc, char **argv)
                         
                         file = fopen (argv[1], "r");
                         g_assert (file != NULL);
+                       buf = g_malloc(readlen);
 
-                        while (TRUE) {
-                                val = fgetc (file);
-                                if (val == EOF)
-                                        break;
-                                buf = (guint) val;
-
-                                fflush(stdout);
+                        while (!feof(file)) {
+                               int nbytes;
+                               nbytes = fread(buf, 1, readlen, file);
 
                                 printf(".");
                                 fflush(stdout);
                                 
-                                if (gdk_pixbuf_loader_write (GDK_PIXBUF_LOADER (pixbuf_loader), &buf, 1) == FALSE)
+                                if (gdk_pixbuf_loader_write (GDK_PIXBUF_LOADER (pixbuf_loader), buf, nbytes) == FALSE)
                                         break;
 
-                                while (gtk_events_pending())
-                                        gtk_main_iteration();
-
+                               while (gtk_events_pending())
+                                       gtk_main_iteration();
                         }
+                       printf("\n");
                        gtk_timeout_remove (timeout);
                         gdk_pixbuf_loader_close (GDK_PIXBUF_LOADER (pixbuf_loader));
                        gtk_object_destroy (GTK_OBJECT(pixbuf_loader));
index c13270fef3451a8019477d5592a24d8a249a59be..d622eac6b8de7b5fce859a4802b97d158d546071 100644 (file)
@@ -1,3 +1,7 @@
+1999-11-02 Elliot Lee <sopwith@redhat.com>
+       * src/testpixbuf.c: Allow using $TBF_READLEN to specify the size of the chunks
+       that are read from the input file.
+
 1999-11-02  Larry Ewing  <lewing@gimp.org>
 
        * src/gnome-canvas-pixbuf.c (gnome_canvas_pixbuf_render): add aa